﻿
namespace GameServer.Model
{
    class World
    {
        public const int REGIONS_X = 8;

        public const int REGIONS_Y = 8; 

        private WorldRegion[,] _worldRegions;

        public World()
        {

            InitRegions();
        }

        private void InitRegions()
        {
            _worldRegions = new WorldRegion[REGIONS_X + 1,REGIONS_Y + 1];

            for (int x = 0; x <= REGIONS_X; x++)
            {
                for(int y = 0; y <= REGIONS_Y; y++)
                {
                    _worldRegions[x, y] = new WorldRegion(x, y);
                }
            }

            for (int x = 0; x <= REGIONS_X; x++)
            {
                for (int y = 0; y <= REGIONS_Y; y++)
                {
                    for (int a = -1; a <= 1; a++)
                    {
                        for (int b = -1; b <= 1; b++)
                        {
                            if (ValidRegion(x + a, y + b))
                            {
                                _worldRegions[x + a, y + b].AddSurroundRegion(_worldRegions[x, y]);
                            }
                        }
                    }
                }
            }
        }

        private bool ValidRegion(int x, int y)
        {
            return (x >= 0 && x <= REGIONS_X && y >= 0 && y <= REGIONS_Y);
        }
    }
}
